package com.amir.common.weight

import android.util.Log
import android.view.View

open class DuplicateClickProxy(var interval: Int, var listener: View.OnClickListener?) :
    View.OnClickListener {
    constructor(listener: View.OnClickListener?) : this(300, listener) {

    }

    private var lastClickTime: Long = 0

    override fun onClick(v: View?) {
        val time = System.currentTimeMillis()
        val timeD = time - lastClickTime
        if (lastClickTime > 0 && timeD < interval) {
            Log.v("isFastDoubleClick", "短时间内按钮多次触发")
            duplicateClick()
            return
        }
        lastClickTime = time
        listener?.onClick(v)
    }

    open fun duplicateClick() {

    }
}